package com.iflytek.cosmo.ocr.common.schedule;

import com.iflytek.cosmo.ocr.service.ExportTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author ViviZhou
 * @create 2019-12-10 16:43
 */
@Component
public class ExportTaskProcessingCleanJob {
    private static final Logger logger = LoggerFactory.getLogger(ExportTaskProcessingCleanJob.class);

    @Value("${file.export.processing.time}")
    private String overTimeMinute;

    @Autowired
    ExportTaskService exportTaskService;

    @Scheduled(cron = "${file.export.processing.clean}")
    public void deleteOverTimeProcessingTask(){
        logger.info("开始查询超时任务");
        //查询超市任务
        List<String> processingOverTimeTaskId = exportTaskService.findOverTimeProcessingTask(Integer.parseInt(overTimeMinute));
        //删除超时任务
        exportTaskService.deleteOverTimeTask(processingOverTimeTaskId);
        logger.info("查询删除任务结束");
    }
}
